#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSqlQueryModel>

namespace Ui {
class MainWindow;
}

enum PAGES {
    P_Start = 0,
    P_Avaible,
    P_Pacient,
    P_Analisys,
    P_Help
};

class InspectionsWidget;
class PassportWidget;
class QMessageBox;
class QFileDialog;

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void setup();
    void clearAll();

    void savePacient(const QString& path);
    bool openPacient(const QString& path);
    bool openPacientFromDb(const int id);

    void updatePacientsList();

    void fromFormToPacient();
    PassportWidget* passportWidget();
    InspectionsWidget* inspectionsWidget();

    int execAskIfNeededToSave();

    void createConnectionsToPacient();
    void closeEvent(QCloseEvent *e);

signals:
    void pacientOpened();
    
private slots:
    void on_actAboutQt_triggered();
    void on_actClearAll_triggered();
    void on_actOpenPacient_triggered();
    void on_actSavePaciet_triggered();
    void on_actAbot_triggered();
    void on_actStart_triggered();
    void on_actPacient_triggered();
    void on_actAnalisys_triggered();
    void on_actHelp_triggered();
    void on_actImport_triggered();
    void on_toolButton_clicked();
    void on_actAddPacient_triggered();
    void on_actExit_triggered();
    void on_actExport_triggered();
    void on_actExportToHTML_triggered();
    void on_actPrint_triggered();
    void on_actionCreate_DB_triggered();
    void on_btnChangeCurDbFile_clicked();

    void on_tblPacients_doubleClicked(const QModelIndex &index);

public slots:
    void showPacientOnForm();
    void markAsModified();

private:
    Ui::MainWindow *ui;

    void decheckAll();
    void changePage(const PAGES p);
    QMessageBox *msgBoxAskIfNeededToSave;
    void selectWhereToSaveAndSave();
    QFileDialog *saveFileDialog;
    QSqlQueryModel mPacientModel;
};

#endif // MAINWINDOW_H
